import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateStudy {
    private String d;
    public DateStudy(String s){
        d=s;
    }

    public DateStudy(){
        this("sss");
    }
    public void mytest(){
        Date d=new Date();
        System.out.println(d);
    }

    @Override
    public String toString() {
        return "DateStudy{" +
                "d='" + d + '\'' +
                '}';
    }




    //时间戳转日期字符串
    public String dateFormat(Date d,String format){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(format);
        return simpleDateFormat.format(d);
    }

    //字符串转时间戳
    public Long getTimeStamp(String date,String format){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(format);
        Date date1= null;
        try {
            date1 = simpleDateFormat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date1.getTime();
    }
    //日期比较

    //日期间隔

    //获取当前时间戳
    public Long  getTimeStamp(){
        Date d=new Date();
        return d.getTime();
    }

    //获取当前年份
    public Integer getYear(String date,String format){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(format);
        try {
            return simpleDateFormat.parse(date).getYear();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
    //获取当前月份

    //获取当前周
}
